home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 23 / Amiga Format AFCD23 (Feb 1998, Issue 107).iso / +look_here_1st!+ / reader_requests / alienbreed3d2 / cd.s < prev    next >
Text File  |  1997-11-28  |  3KB  |  233 lines

  1. ;
  2. ; cd.s - cd player for AB3D (C)opyright 1995 Team17 Ltd - Charlie
  3. ; $Log: $
  4. ;
  5. ;
  6.  
  7.  
  8.     opt    L-,O+,P=68020
  9.  
  10.     INCDIR    utils:sysinc/
  11.     INCLUDE exec/exec_lib.i        ; change this for your path!.
  12.     INCLUDE exec/io.i
  13.     INCLUDE devices/cd.i
  14.  
  15.  
  16.     XREF    _CreatePort
  17.     XREF    _CreateExtIO
  18.     XREF    _DeleteExtIO
  19.     
  20.     XREF    _DOSBase            ; Need _DOSBase defined and Filled!
  21.     XDEF    _SysBase
  22.  
  23.  
  24.  
  25. _test
  26.     bsr    _InitCD
  27.     tst.l    d0
  28.     beq.s    .BadOpen
  29.  
  30.     moveq    #1,d0
  31.     bsr    _PlayCD
  32.     bsr    _StopCD
  33.     bsr    _CloseCD
  34.  
  35.     moveq    #0,d0
  36.  
  37.  
  38. .BadOpen
  39.     rts
  40.  
  41.  
  42. ; end test routine..
  43.  
  44.  
  45.  
  46.     XDEF    _InitCD
  47.  
  48. _InitCD
  49.  
  50. ; setup execbase 
  51.  
  52.     lea    Data(pc),a4
  53.     move.l    4.w,_ExecBase-Data(a4)
  54.     move.l    _ExecBase(pc),a6
  55.  
  56. ; setup port 
  57.  
  58.     sub.l    a0,a0
  59.     moveq    #0,d0
  60.     jsr    _CreatePort
  61.     tst.l    d0
  62.     beq.b    .PortError
  63.  
  64.     move.l    d0,_CDPort-Data(a4)        ; MsgPort for cd.device
  65.  
  66. ; Create first extended io port
  67.  
  68.     move.l    d0,a0
  69.     moveq    #IOSTD_SIZE,d0        ; sizeof strct IORequest
  70.     jsr    _CreateExtIO
  71.     tst.l    d0
  72.     beq.b    .PortError
  73.  
  74.     move.l    d0,_CDReq0-Data(a4)
  75.  
  76. ; Create second extended io port
  77.  
  78.     move.l    _CDPort(pc),a0
  79.     moveq    #IOSTD_SIZE,d0
  80.     jsr    _CreateExtIO
  81.     tst.l    d0
  82.     beq.b    .PortError
  83.  
  84.     move.l    d0,_CDReq1-Data(a4)        ; second EXTIO
  85.  
  86. ; open device..
  87.  
  88.     lea    _CDDev(pc),a0
  89.     moveq    #0,d0                ; unit number
  90.     move.l    _CDReq0(pc),a1
  91.     moveq    #0,d1                ; flags.
  92.     jsr    _LVOOpenDevice(a6)
  93.     tst.l    d0
  94.     beq.b    .PortOk
  95.     bra.b    .PortError
  96.  
  97. .PortOk
  98.     move.l    _CDReq0(pc),a0
  99.     move.l    _CDReq0(pc),a1
  100.  
  101. ; copy _CDReq0 -> _CDReq1
  102.  
  103.     moveq    #20/4,d0
  104. .loop
  105.     move.l    (a0),(a1)
  106.     dbra    d0,.loop
  107.  
  108.  
  109.     moveq    #1,d0                ; return value
  110.     move.l    d0,_CDAvail-Data(a4)
  111.     rts
  112.  
  113. .PortError
  114.     moveq    #0,d0                ; return value for error..
  115.     move.l    d0,_CDAvail-Data(a4)
  116.     rts
  117.  
  118.  
  119.     XDEF    _PlayCD
  120.  
  121. _PlayCD
  122.  
  123.     lea    Data(pc),a4
  124.  
  125.  
  126.     cmp.l    #0,_CDAvail-Data(a4)
  127.     bne.b    .CDOk
  128.  
  129.     moveq    #0,d0
  130.     rts
  131.  
  132. .CDOk
  133.     move.l    d0,-(sp)
  134.  
  135. ; kill any current activity..
  136.  
  137.     bsr.b    _StopCD
  138.  
  139.     move.l    _CDReq0(pc),a1
  140.     move.w    #CD_PLAYTRACK,IO_COMMAND(a1)
  141.     move.l    (sp)+,d0
  142.  
  143.     move.l    d0,IO_OFFSET(a1)        ; play from
  144.     move.l    #1,IO_LENGTH(a1)        ; number of tracks to play for
  145.  
  146.     move.l    _ExecBase(pc),a6
  147.     jsr    _LVOSendIO(a6)
  148.  
  149.  
  150.     rts
  151.  
  152.  
  153.     XDEF    _StopCD
  154.  
  155. _StopCD
  156.  
  157.     lea    Data(pc),a4
  158.  
  159. ; check if CDReq0 is being used or not...
  160.  
  161.     move.l    _CDReq0(pc),a1
  162.     move.l    _ExecBase(pc),a6
  163.     jsr    _LVOCheckIO(a6)
  164.     tst.l    d0
  165.     bne.b    .NotUsed
  166.  
  167.     jsr    _LVOAbortIO(a6)
  168. .NotUsed
  169.  
  170.  
  171.     rts
  172.  
  173.  
  174.     XDEF    _CloseCD
  175.  
  176. _CloseCD
  177.  
  178.     move.l    _CDReq0(pc),a1
  179.     move.l    _ExecBase(pc),a6
  180.     jsr    _LVOCloseDevice(a6)
  181.  
  182.     move.l    _CDReq0(pc),a0
  183.     jsr    _DeleteExtIO
  184.     
  185.     rts
  186.  
  187.     XDEF    _CDPos
  188.  
  189. _CDPos
  190.     lea    Data(pc),a4
  191.  
  192. ; check if CDReq0 is being used or not...
  193.  
  194.     move.l    _CDReq0(pc),a1
  195.     move.l    _ExecBase(pc),a6
  196.     jsr    _LVOCheckIO(a6)
  197.     tst.l    d0
  198.     bne.b    .NotUsed
  199.     moveq    #-1,d0
  200.  
  201. .NotUsed
  202.         
  203.     rts
  204.  
  205. ;            Data Section
  206.  
  207. Data
  208.     CNOP    0,4
  209.  
  210. _ExecBase
  211. _SysBase
  212.     dc.l    0
  213.  
  214. _CDAvail
  215.     dc.l    0
  216.  
  217. _CDPort
  218.     dc.l    0
  219.  
  220. _CDReq0
  221.     dc.l    0
  222.  
  223. _CDReq1
  224.     dc.l    0
  225.  
  226. _QCode
  227.     dcb.b    1000,0
  228.  
  229. _CDDev:
  230.     dc.b    "cd.device",0
  231.  
  232.     END
  233.